package com.bidevalution.controller.ureport;

import com.qtp.core.util.OConvertUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ReportCommon {
    private static final String CODE_STR = "c";
    public static List<Map<String,Object>> pushData(List<Map<String, Object>> dataList) {
        List<Map<String,Object>> list = new ArrayList<Map<String,Object>>();
        if (dataList != null && !dataList.isEmpty()) {
            Map<String, Object> data;
            for (int i = 0; i < dataList.size(); i++) {
                data = dataList.get(i);
                String enterPriseId = OConvertUtils.getString(data.get("enterprise_id"));
                String assessorsVal;
                Map<String, Object> item;
                String code;
                for (int j = 1; j < 21; j++) {
                    code = String.format("%s%s", CODE_STR, j);
                    assessorsVal = OConvertUtils.getString(data.get(code));
                    if (OConvertUtils.isNotEmpty(assessorsVal)) {
                        item = new HashMap<>(4);
                        item.put("enterprise_id", enterPriseId);
                        item.put("code", code);
                        item.put("value", data.get(code));
                        list.add(item);
                    }
                }
            }
        }
        return list;
    }
}
